package com.ft.oa.web.development;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ft.oa.domain.development.DevNeed;
import com.ft.oa.domain.development.DevProduct;
import com.ft.oa.domain.development.NeedAnalyse;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.domain.industrys.IndustryDoc;
import com.ft.oa.service.development.DevNeedAnalyseService;
import com.ft.oa.service.development.DevProductService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Map;

@RestController
@RequestMapping("/dev/analyse")
public class DevNeedAnalyseController {

    @Resource
    private DevNeedAnalyseService devNeedAnalyseService;


    /**
     * 需求分析主列表查询
     */
    @PostMapping("/page")
    public ApiResult page(@RequestBody DevNeed devNeed) {

        Page<DevNeed> page = devNeedAnalyseService.page(devNeed);

        return ApiResult.successWithData(page);
    }

    /**
     * 新增需求分析文档
     */
    @PostMapping("/addNeedAttachment")
    private ApiResult addNeedAttachment(@RequestBody NeedAnalyse needAnalyse){
        ApiResult result = devNeedAnalyseService.addNeedAttachment(needAnalyse);
        return result;
    }


    /**
     * 需求分析文档分页查询
     */
    @PostMapping("/needAnalysePage")
    public ApiResult needAnalysePage(@RequestBody Map<String,Object> params) {
        Page<NeedAnalyse> page = devNeedAnalyseService.needAnalysePage(params);
        return ApiResult.successWithData(page);
    }

    /**
     * 编辑附件信息
     * @param needAnalyse
     * @return
     */

    @PostMapping("/needAnalyseUpdate")
    public ApiResult needAnalyseUpdate(@RequestBody NeedAnalyse needAnalyse) {
        devNeedAnalyseService.needAnalyseUpdate(needAnalyse);
        return ApiResult.simpleSuccess();
    }

    /**
     * 删除附件
     * @return
     */
    @PostMapping("/needAnalyseDelete")
    public ApiResult needAnalyseDelete(@RequestBody NeedAnalyse needAnalyse){
        devNeedAnalyseService.needAnalyseDelete(needAnalyse);
        return ApiResult.simpleSuccess();
    }

}
